
<%@ include file="../common.jsp"%>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#location").attr("action",'<c:url value="/saveLocation.htm"></c:url>');
				$("#locationName").focus();
			});
		
</script>
<form:form commandName="locationForm" id="location">
	<table class="adminFilterTable">
		<tr class="tableChildHeaderColor">
			<th colspan="5" align="center"> ADD NEW BUISNESS UNIT </th>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr> 
			<td align="left" colspan="5" style="font-family: verdana; font-size: 12px;"> All fields are mandatory.</td> 
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Name </td>	
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:input path="ldName" id="locationName"/> 
				 <form:errors path="ldName" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Code </td>
			<td class="spacingColumnWidthLess"></td>	
			<td class="formField"> <form:input path="ldCode"/> 
				 <form:errors path="ldCode" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Company Name </td>
			<td class="spacingColumnWidthLess"></td>	
			<td class="formField"> <form:select path="ldCompanyId.cdId">
					 <form:option value="0">Choose Company</form:option>
					 <c:forEach var="companyList" items="${companyList}">
						<form:option value="${companyList.cdId}">${companyList.cdName}</form:option>
					 </c:forEach>
				 </form:select>
				 <form:errors path="ldCompanyId.cdId" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Type </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:select path="ldType">
					<form:option value="0">Choose Unit</form:option>
					<c:forEach var="bUList" items="${bUList}">
						<form:option value="${bUList.buTypeName}">${bUList.buTypeName}</form:option>
					</c:forEach>
				</form:select>
				<form:errors path="ldType" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Department </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> 
				<c:forEach var="departmentMap" items="${departmentMap}">
					<form:checkbox path="ddId" value="${departmentMap.key}" label="${departmentMap.value}"/>
				</c:forEach>
				<form:errors path="ddId" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr align="left">
			<td class="spacingColumnWidthLess"></td>
			<td></td>
			<td class="spacingColumnWidthLess"></td>
			<td colspan="2"> <input class="formButton ui-corner-all" type="button" value="SAVE" onclick="javascript:addEntity('location')"> </td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
	</table>
</form:form>

<c:if test="${errorCount eq 0}">
	<c:choose>
		<c:when test="${resultOfEntry}">
			Operation Done Successfully
		</c:when>
		<c:otherwise>
			<label class="errorMsg"> Error. Business Unit Already Exists. </label>
		</c:otherwise>
	</c:choose>
</c:if>